<template>
  <a-card :bordered="false">
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange">
      <span slot="actionName">
        <a-button size="small" @click="handleAdd('文书制作-新增')" type="primary" icon="plus">新增</a-button>
      </span>
      <span slot="action" slot-scope="text, record">
        <template v-if="record.fileName !==''">
          <a @click="handleDownload(record)">下载</a>
          <a-divider type="vertical"/>
        </template>
        <a @click="handleEdit(record,'文书制作-编辑')">编辑</a>
        <a-divider type="vertical"/>
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
          <a>删除</a>
        </a-popconfirm>
      </span>
    </a-table>
    <!-- table区域-end -->
    <CheckAndEditModel ref="modalForm" @ok="modalFormOk"></CheckAndEditModel>
  </a-card>
</template>

<script>
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import CheckAndEditModel from './CheckAndEditModel'
  import {httpAction, getAction} from '@/api/manage'
  import "moment/locale/zh-cn"
  import columns from "./indexColumns"

  export default {
    name: '文件模板维护',
    mixins: [JeecgListMixin],
    components: {
      CheckAndEditModel
    },
    data() {
      return {
        // 表头
        columns: columns(this),
        url: {
          list: '/xtsz/sjWordTemplate/list',
          delete: '/xtsz/sjWordTemplate/delete'
        }
      }
    },
    computed: {},
    methods: {
      handleDownload(record) {
        this.$message.success('正在下载，请稍等！')
        let url = `${window._CONFIG['domianURL']}/sys/common/download${record.tempUrl}`
        window.open(url, '_blank')
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>